var app = getApp();

Page({
    data:{
      url:'1',
        winHeight:"",
        currentTab:0, 
        scrollLeft:0, 
        expertList:[{ 
          tabTitle:'FM92.1'
        },{ 
          tabTitle:'河南交通广播'
        }
      ],
      fmtList:[],
      fixedProgramList: [
        { name: "早间新闻", description: "6:00 - 7:00" },
        { name: "音乐时间", description: "7:00 - 8:00" },
        { name: "交通路况", description: "8:00 - 9:00" },
        { name: "午间新闻", description: "12:00 - 13:00" },
        { name: "晚间音乐会", description: "19:00 - 21:00" }
      ]
    },
    // 滚动切换标签样式
    switchTab:function(e){
        this.setData({
            currentTab:e.detail.current
        });
        this.checkCor();
    },
    // 点击标题切换当前页时改变样式
    swichNav:function(e){
        var cur=e.target.dataset.current;
        if(this.data.currentTaB==cur){return false;}
        else{
            this.setData({
                currentTab:cur
            })
        }
    },
    //判断当前滚动超过一屏时，设置tab标题滚动条。
    checkCor:function(){
      if (this.data.currentTab>4){
        this.setData({
          scrollLeft:300
        })
      }else{
        this.setData({
          scrollLeft:0
        })
      }
    },
    onLoad: function() {  
      this.setData({
        url:app.globalData.URL
      })

      console.log("url is "+this.data.url)
        var that = this; 
        //  高度自适应
        wx.getSystemInfo( {  
            success: function( res ) {  
                var clientHeight=res.windowHeight,
                    clientWidth=res.windowWidth,
                    rpxR=750/clientWidth;
              var  calc=clientHeight*rpxR-180;
                console.log(calc)
                that.setData( {  
                    winHeight: calc  
                });  
                  wx.request({
                    url: that.data.url+'fm/selectAll?pageNum=1&pageSize=9',
                    success(resp){
                      that.setData({
                        fmList:resp.data.data.list
                      
                      })
                     
                    }
                  });
              
            }  
        });
    },  
    footerTap:app.footerTap
})